home *** CD-ROM | disk | FTP | other *** search
/ 15 Beaut Aussie Games 1 / BEAUTGAMESV1.iso / pc / Windows / data1.cab / Program_Files / dswmedia / games / canetoad.dcr / hero_1_hero parent.ls < prev    next >
Encoding:
Text File  |  2002-01-01  |  5.0 KB  |  193 lines

  1. property sNumber, sCast, action, hOff, vOff, hInit, vInit, hIncr, vIncr, animCel, maxIncr, limits, sNumberShad, hShad, vShad
  2.  
  3. on new me
  4.   sNumber = 22
  5.   puppetSprite(sNumber, 1)
  6.   sCast = the castLibNum of sprite sNumber
  7.   hInit = 197
  8.   vInit = 200
  9.   sNumberShad = 2
  10.   puppetSprite(sNumberShad, 1)
  11.   hShad = 21
  12.   vShad = 14
  13.   init(me)
  14.   return me
  15. end
  16.  
  17. on init me
  18.   hOff = 0
  19.   vOff = 0
  20.   hIncr = 0
  21.   vIncr = 0
  22.   animCel = 1
  23.   maxIncr = 10
  24.   limits = [75, 50, 325, 250]
  25.   action = "stand"
  26.   set the loc of sprite sNumber to point(hInit, vInit)
  27.   set the member of sprite sNumber to member("still", sCast)
  28.   set the loc of sprite sNumberShad to the loc of sprite sNumber + point(hShad, vShad)
  29.   set the member of sprite sNumberShad to member("stillShad", sCast)
  30.   set the keyDownScript to "checkKeys hero"
  31. end
  32.  
  33. on checkKeys me
  34.   global gameControl
  35.   case the keyCode of
  36.     5:
  37.       if the optionDown then
  38.         gameControl.action = "levelDone"
  39.         endLevel(me)
  40.       end if
  41.     0, 126:
  42.       Up(me)
  43.     6, 125:
  44.       down(me)
  45.     43, 123:
  46.       if action = "right" then
  47.         stand(me)
  48.       else
  49.         left(me)
  50.       end if
  51.     47, 124:
  52.       if action = "left" then
  53.         stand(me)
  54.       else
  55.         right(me)
  56.       end if
  57.     49:
  58.       stand(me)
  59.   end case
  60. end
  61.  
  62. on move me
  63.   global gameControl
  64.   case action of
  65.     "left", "right", "up", "down":
  66.       set the loc of sprite sNumber to the loc of sprite sNumber + point(hIncr, vIncr)
  67.       set the loc of sprite sNumberShad to the loc of sprite sNumber + point(hShad, vShad)
  68.       if (the locH of sprite sNumber <= getAt(limits, 1)) or (the locH of sprite sNumber >= getAt(limits, 3)) or (the locV of sprite sNumber <= getAt(limits, 2)) or (the locV of sprite sNumber >= getAt(limits, 4)) then
  69.         set the loc of sprite sNumber to the loc of sprite sNumber - point(hIncr, vIncr)
  70.         set the loc of sprite sNumberShad to the loc of sprite sNumber + point(hShad, vShad)
  71.         stand(me)
  72.         updateStage()
  73.       end if
  74.   end case
  75. end
  76.  
  77. on moveToFinished me
  78.   global gameControl
  79.   if abs(209 - the locH of sprite sNumber) > 6 then
  80.     if (209 - the locH of sprite sNumber) > 0 then
  81.       hIncr = 4
  82.     else
  83.       hIncr = -4
  84.     end if
  85.   else
  86.     set the locH of sprite sNumber to 209
  87.     hIncr = 0
  88.   end if
  89.   if abs(90 - the locV of sprite sNumber) > 6 then
  90.     if (90 - the locV of sprite sNumber) > 0 then
  91.       vIncr = 4
  92.     else
  93.       vIncr = -4
  94.     end if
  95.   else
  96.     set the locV of sprite sNumber to 90
  97.     vIncr = 0
  98.   end if
  99.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hIncr, vIncr)
  100.   if sqrt(((90 - the locV of sprite sNumber) * (90 - the locV of sprite sNumber)) + ((209 - the locH of sprite sNumber) * (209 - the locH of sprite sNumber))) <= 10 then
  101.     gameControl.action = "finished"
  102.   end if
  103. end
  104.  
  105. on stand me
  106.   set the loc of sprite sNumber to the loc of sprite sNumber - point(hOff, vOff)
  107.   hOff = 0
  108.   vOff = 0
  109.   hIncr = 0
  110.   vIncr = 0
  111.   animCel = 1
  112.   action = "stand"
  113.   set the member of sprite sNumber to member("still", sCast)
  114.   set the member of sprite sNumberShad to member("stillShad", sCast)
  115. end
  116.  
  117. on Up me
  118.   hOff = 0
  119.   vOff = 0
  120.   hIncr = 0
  121.   vIncr = -maxIncr
  122.   animCel = 1
  123.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hOff, vOff)
  124.   action = "up"
  125.   set the member of sprite sNumber to member("up", sCast)
  126.   set the member of sprite sNumberShad to member("stillShad", sCast)
  127. end
  128.  
  129. on down me
  130.   hOff = 0
  131.   vOff = 0
  132.   hIncr = 0
  133.   vIncr = maxIncr
  134.   animCel = 1
  135.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hOff, vOff)
  136.   action = "down"
  137.   set the member of sprite sNumber to member("down", sCast)
  138.   set the member of sprite sNumberShad to member("stillShad", sCast)
  139. end
  140.  
  141. on left me
  142.   hOff = 0
  143.   vOff = 0
  144.   hIncr = -maxIncr
  145.   vIncr = 0
  146.   animCel = 1
  147.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hOff, vOff)
  148.   action = "left"
  149.   set the member of sprite sNumber to member("left", sCast)
  150.   set the member of sprite sNumberShad to member("leftShad", sCast)
  151. end
  152.  
  153. on right me
  154.   hOff = 0
  155.   vOff = 0
  156.   hIncr = maxIncr
  157.   vIncr = 0
  158.   animCel = 1
  159.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hOff, vOff)
  160.   action = "right"
  161.   set the member of sprite sNumber to member("right", sCast)
  162.   set the member of sprite sNumberShad to member("rightShad", sCast)
  163. end
  164.  
  165. on die me
  166.   global gameControl
  167.   hOff = 0 - hOff
  168.   vOff = 0 - vOff
  169.   hIncr = 0
  170.   animCel = 1
  171.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hOff, vOff)
  172.   puppetSound(2, "pow")
  173.   puppetSound(1, "sigh")
  174.   action = "dead"
  175.   gameControl.action = "dead"
  176.   set the member of sprite sNumber to member("die", sCast)
  177.   set the loc of sprite sNumberShad to point(-200, -200)
  178.   set the keyDownScript to EMPTY
  179. end
  180.  
  181. on endLevel me
  182.   global gameControl
  183.   hOff = 0 - hOff
  184.   vOff = 0 - vOff
  185.   hIncr = 0
  186.   animCel = 1
  187.   set the loc of sprite sNumber to the loc of sprite sNumber + point(hOff, vOff)
  188.   action = "endLevel"
  189.   set the member of sprite sNumber to member("endLevel", sCast)
  190.   set the loc of sprite sNumberShad to point(-200, -200)
  191.   set the keyDownScript to EMPTY
  192. end
  193.